<?php
/*
	首页
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$mid=$_RQ['mid'];
	if(!$mid && !$_RQ['ismy']){
		exi('该用户未绑定会员ID！','error');
	}
	$member=$this->model('member')->get_member($mid);
	$member['credit1passtime']=date('Y年m月d日',time()+7*24*3600);
	$this->session('mid',$member['mid']);
	$return['member']=$member;
	$return['params']=array('type'=>$_RQ['type']?:2);
	$return['list']=array();
	$sharelink='jy_ailiao/quan//type='.$_RQ['type'].'&fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$return['pluginset']['share_title']?:'动态列表',
			'desc'=>$return['pluginset']['share_desc']?:'动态列表，成就天下姻缘！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($return['pluginset']['share_image'])
	);
	set_html('title','动态列表');
	exi($return);
}
if($_RQ['op']=='getquanlog'){
	//获取最近50家店
	if(intval($_RQ['lat'])){
		$lat_lng=array('lat'=>$_RQ['lat'],'lng'=>$_RQ['lng']);
		$this->session('lat_lng',$lat_lng);
	}
	$lat_lng=$this->session('lat_lng');
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
		'noshow'=>0,
		'simi'=>0,
	);
	if($this->session('mid')){
		$params['mid']=$this->session('mid');
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,8),
		'fields'=>'',
		'key'=>'id',
		'orderby'=>$orderby,
		'orderbykey'=>$orderbykey,
	);
	$logs=$this->model('member')->getlogs($parameter,6,$lat_lng,intval($_RQ['page']),intval($_RQ['juli']));
	foreach($logs as $k=>&$v){
		$v['logo']=$v['logo']?tomedia($v['logo']):'';
		$v['topimg']=$v['topimg']?tomedia($v['topimg']):'';
		$v['createtime']=date('Y-m-d',$v['createtime']);
		$v['images']=json_decode($v['images'],true);
		foreach($v['images'] as &$iv){
			$iv=tomedia($iv);
		}
	}
	$return['list']=array_values($logs);
	exi($return);
}
?>